﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;
using Common.Views;
using ElectroSystem.Models;

namespace ElectroSystem.Controllers
{
    public class HomeController : MenusController
    {
       
        public ActionResult Index()
        {
            ViewBag.Message = "Electros Ltd";
            HomeModel hm = new HomeModel();
            return View(hm);
        }

        public PartialViewResult GetProductsByCategory(int categoryID)
        {
            List<Product> products = new ProductsServ.ProductsServiceClient().GetProductsByCategoryRefinement(categoryID).ToList();
            return PartialView("_categoryprod", products);
        }

        public PartialViewResult Search(string keyword)
        {
            List<Product> p = new ProductsServ.ProductsServiceClient().SearchProductByName(keyword).ToList();
            return PartialView("_searchname", p);
        }

        public PartialViewResult SearchByPrice(decimal minPrice, decimal maxPrice)
        {
            List<Product> p = new ProductsServ.ProductsServiceClient().SearchProductByPrice(minPrice, maxPrice).ToList();
            return PartialView("_searchprice", p);
        }

        public PartialViewResult SearchByPriceASC()
        {
            List<Product> products = new ProductsServ.ProductsServiceClient().SearchProductByPriceASC().ToList();
            return PartialView("_searchprice", products);
        }

        public PartialViewResult SearchByPriceDESC()
        {
            List<Product> products = new ProductsServ.ProductsServiceClient().SearchProductByPriceDESC().ToList();
            return PartialView("_searchprice", products);
        }

        public PartialViewResult SearchByDateListed()
        {
            List<Product> products = new ProductsServ.ProductsServiceClient().SearchProductByDateASC().ToList();
            return PartialView("_searchprice", products);
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
